87398500, 87398980, 87398900, 87398950, 87405500, 87406900, 87409900
| 1990-2000 | 2000-2010 | 2010-2020 |
|---|---|---|
| 1990-2000 | 2000-2010 | 2010-2020 |
# install.packages(tidyverse)# library(readr)
# library(rmarkdown)
# # library(qboxplot)
# library(readxl)
# library(pillar)
# library(dplyr)
# library(tidyverse)
# library(gapminder)
# library(knitr)
# library(kableExtra)
# library(ggpubr)
# library(gridExtra)
# library(modelsummary)
# library(gtsummary)
# library(GGally)
pacman::p_load(readr, rmarkdown, readxl,
pillar, dplyr, tidyverse,
gapminder, knitr, kableExtra,
gridExtra, #modelsummary,
gtsummary, ggplot2,
ggbeeswarm, GGally)
# pacman::p_load(tibbletime)knitr::knit_hooks$set(time_it = local({
now <- NULL
function(before, options) {
if (before) {
# record the current time before each chunk
now <<- Sys.time()
} else {
# calculate the time difference after a chunk
res <- difftime(Sys.time(), now)
# return a character string to show the time
paste("Time for this code chunk to run:", res)
}
}
}))
knitr::opts_chunk$set(time_it = TRUE)
plan_wide_19902020 <- plan_wide_19902020 %>%
mutate(IQA = ifelse(IQA == 0, NA, IQA))theme_grafs <- function(bg = "white",
coloracao_letra = "black") {
theme(
plot.title = element_text(
hjust = 0.5,
color = coloracao_letra,
size = 19),
axis.title.x =
# element_text(
# color = coloracao_letra,
# size = 15,
# angle = 0,),
element_blank(),
axis.title.y = element_text(
color = coloracao_letra,
size = 15,
angle = 90),
axis.text.x = element_text(
color = coloracao_letra,
size = 17),
axis.text.y = element_text(
color = coloracao_letra,
size = 17,
angle = 0),
panel.background = element_rect(fill = bg),
plot.background = element_rect(fill = bg),
plot.margin = margin(l = 5, r = 10,
b = 5, t = 5)
)
}# p1 <- plan_wide_19902020 %>%
# filter(ANO_COLETA > "1990" &
# ANO_COLETA <= "2000")
#
# p2 <- plan_wide_19902020 %>%
# filter(ANO_COLETA > "2000" &
# ANO_COLETA <= "2010")
#
# p3 <- plan_wide_19902020 %>%
# filter(ANO_COLETA > "2010" &
# ANO_COLETA <= "2020")
# teste_all_periodos <- plan_wide_19902020 %>%
# filter(
# between(ANO_COLETA, 1990, 2000)
# )p1 <- plan_wide_19902020 %>%
filter(ANO_COLETA > "1990" &
ANO_COLETA <= "2000")
p2 <- plan_wide_19902020 %>%
filter(ANO_COLETA > "2000" &
ANO_COLETA <= "2010")
p3 <- plan_wide_19902020 %>%
filter(ANO_COLETA > "2010" &
ANO_COLETA <= "2020")
# periodo = c(p1 <- plan_wide_19902020 %>%
# filter(ANO_COLETA > "1990" &
# ANO_COLETA <= "2000"),
#
# p2 <- plan_wide_19902020 %>%
# filter(ANO_COLETA > "2000" &
# ANO_COLETA <= "2010"),
#
# p3 <- plan_wide_19902020 %>%
# filter(ANO_COLETA > "2010" &
# ANO_COLETA <= "2020"))
# sumario <- function(parametros = parametros, periodo){
# plan_wide_19902020 %>%
# select(CODIGO, ., ANO_COLETA) %>%
# # filter(ANO_COLETA>"1990" &
# # ANO_COLETA<="2000") %>%
# group_by(CODIGO) %>%
# summarize(
# min =
# min(parametros,
# na.rm = TRUE),
# q1 =
# quantile(parametros, 0.25,
# na.rm = TRUE),
# median =
# median(parametros,
# na.rm = TRUE),
# mean =
# mean(parametros,
# na.rm= TRUE),
# q3 =
# quantile(parametros, 0.75,
# na.rm = TRUE),
# max =
# max(parametros,
# na.rm = TRUE))
# }
# plan_wide_19902020 %>%
# sumario(parametros = DBO)
# sum_IQA_p1 <- plan_wide_19902020 %>%
# select(CODIGO, IQA, ANO_COLETA) %>%
# filter(ANO_COLETA>"1990" &
# ANO_COLETA<="2000") %>%
# group_by(CODIGO) %>%
# summarize(
# min =
# min(IQA,
# na.rm = TRUE),
# q1 =
# quantile(IQA, 0.25,
# na.rm = TRUE),
# median =
# median(IQA,
# na.rm = TRUE),
# mean =
# mean(IQA,
# na.rm= TRUE),
# q3 =
# quantile(IQA, 0.75,
# na.rm = TRUE),
# max =
# max(IQA,
# na.rm = TRUE))# par_od <- plan_wide_19902020 %>%
# select(CODIGO, `Oxigênio dissolvido`) %>%
# group_nest(CODIGO)
# parametros_IQA
# parametros <- colnames(parametros_IQA)[]
plan_wide_19902020 %>%
ggplot(
aes(CODIGO, `Oxigênio dissolvido`)
)+
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin = -Inf, ymax = 2,
alpha = 1,
fill = "#ac5079")+ # >pior classe
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin = 2, ymax = 4,
alpha = 1,
fill = "#eb5661")+ #classe 4
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin = 4, ymax = 5,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=5,
ymax=6,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=6,
ymax=Inf,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(
geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65)
)+
geom_boxplot(
fill = '#F8F8FF',
color = "black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7
)+
labs(
title = "Oxigênio Dissolvido no período 1990-2000",
x = "Estação",
y = "mg/L"
)+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(
expand = expansion(mult = c(0,0)),
n.breaks = 11,
limits = c(-1,21)
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)## Warning: Removed 92 rows containing non-finite values (stat_boxplot).
## Removed 92 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 92 rows containing missing values (position_quasirandom).
Oxigênio Dissolvido no período 1990-2000
grid.arrange(od_p1, od_p2, od_p3, ncol = 3)Oxigênio Dissolvido no período 1990-2020
ggsave("od_p1.png",
plot = od_p1,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Removed 7 rows containing non-finite values (stat_boxplot).
## Removed 7 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 7 rows containing missing values (position_quasirandom).
ggsave("od_p2.png",
plot = od_p2,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Removed 54 rows containing non-finite values (stat_boxplot).
## Removed 54 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 54 rows containing missing values (position_quasirandom).
ggsave("od_p3.png",
plot = od_p3,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Removed 31 rows containing non-finite values (stat_boxplot).
## Removed 31 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 31 rows containing missing values (position_quasirandom).
ggsave("od_3periodos_2.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(od_p1, od_p2, od_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")## Warning: Removed 7 rows containing non-finite values (stat_boxplot).
## Warning: Removed 7 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 7 rows containing missing values (position_quasirandom).
## Warning: Removed 54 rows containing non-finite values (stat_boxplot).
## Removed 54 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 54 rows containing missing values (position_quasirandom).
## Warning: Removed 31 rows containing non-finite values (stat_boxplot).
## Removed 31 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 31 rows containing missing values (position_quasirandom).
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
grid.arrange(iqaod_p1, iqaod_p2, iqaod_p3, ncol = 3)Resultado que quero chegar pro sumário
| variable | Estação 1 | Estação 2 | Estação 3 | Estação 4 |
|---|---|---|---|---|
| max | 15 | 17 | 16 | 14 |
| med | 14 | 16 | 15 | 13 |
| min | 13 | 15 | 14 | 12 |
| n | 15 | 12 | 3 | 4 |
## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.8 4.9 6.4 5.99 7.3 10.8
## 2 87398900 2 5.6 6.9 6.78 8 10.5
## 3 87398950 2.5 4.4 5.95 5.98 7.1 10.3
## 4 87398980 4.2 6 6.3 7.01 8.2 12.1
## 5 87405500 0.1 1.9 4.2 4.22 6 19.9
## 6 87406900 0.1 0.25 2.6 2.98 5 10.2
## 7 87409900 0.1 1.4 2.9 3.60 5.65 11.1
## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.4 3.5 4.9 5.01 6.65 10.9
## 2 87398900 1.9 4 5.5 5.33 6.6 12
## 3 87398950 1.7 3.2 5.3 5.06 6.18 8.9
## 4 87398980 1.2 3.8 5.6 5.38 6.6 9.2
## 5 87405500 0.2 1.4 2.55 3.28 4 14.2
## 6 87406900 0 1.1 1.9 2.59 3.15 16
## 7 87409900 0 0.7 2.3 3.12 3.7 10.6
## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.38 3.11 4.41 4.57 6.2 12.4
## 2 87398900 3.52 5.25 5.96 6.61 7.3 13.8
## 3 87398950 1.62 3.68 4.92 5.28 6.64 11.9
## 4 87398980 3.37 5.5 6.17 6.48 7.14 13.1
## 5 87405500 0.2 1.3 2.53 2.83 3.66 9.8
## 6 87406900 0.1 0.865 2.4 2.43 3.05 9.1
## 7 87409900 0.1 0.92 2.03 2.43 3.5 8.1
grid.arrange(dbo_p1, dbo_p2, dbo_p3, ncol = 3)(sum_dbo_p1 <- plan_wide_19902020 %>%
select(CODIGO, DBO, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(DBO,
na.rm = TRUE),
q1 =
quantile(DBO, 0.25,
na.rm = TRUE),
median =
median(DBO,
na.rm = TRUE),
mean =
mean(DBO,
na.rm= TRUE),
q3 =
quantile(DBO, 0.75,
na.rm = TRUE),
max =
max(DBO,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 1 1 2 1.86 2 13
## 2 87398900 1 1 1 1.52 2 6
## 3 87398950 1 1 1 1.66 2 6
## 4 87398980 1 1 1 1.13 1 2
## 5 87405500 1 2 3 5.37 5 64
## 6 87406900 1 4 5 9 11 26
## 7 87409900 2 3 4 6.97 9.5 31
(sum_dbo_p2 <- plan_wide_19902020 %>%
select(CODIGO, DBO, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(DBO,
na.rm = TRUE),
q1 =
quantile(DBO, 0.25,
na.rm = TRUE),
median =
median(DBO,
na.rm = TRUE),
mean =
mean(DBO,
na.rm= TRUE),
q3 =
quantile(DBO, 0.75,
na.rm = TRUE),
max =
max(DBO,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 1 1 1 1.58 2 5
## 2 87398900 1 1 1 1.40 2 5
## 3 87398950 1 1 1 1.66 2 5
## 4 87398980 1 1 1 1.30 1 5
## 5 87405500 1 2 4 4.67 6.5 14
## 6 87406900 1 3 5 6.53 8 28
## 7 87409900 1 3 6 6.31 9 15
(sum_dbo_p3 <- plan_wide_19902020 %>%
select(CODIGO, DBO, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(DBO,
na.rm = TRUE),
q1 =
quantile(DBO, 0.25,
na.rm = TRUE),
median =
median(DBO,
na.rm = TRUE),
mean =
mean(DBO,
na.rm= TRUE),
q3 =
quantile(DBO, 0.75,
na.rm = TRUE),
max =
max(DBO,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 1 1 1.5 2.15 3 7
## 2 87398900 1 1 1 1.51 2 5
## 3 87398950 1 1 2 2.65 2 18
## 4 87398980 1 1 1 1.32 2 2
## 5 87405500 1 3 4 5.28 6.25 21
## 6 87406900 1 3 5 6.58 10 24
## 7 87409900 1 3 4.5 6.18 8 18
ggsave("dbo_p1.png",
plot = dbo_p1,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 22 rows containing non-finite values (stat_boxplot).
## Removed 22 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 22 rows containing missing values (position_quasirandom).
ggsave("dbo_p2.png",
plot = dbo_p2,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 30 rows containing non-finite values (stat_boxplot).
## Removed 30 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 30 rows containing missing values (position_quasirandom).
ggsave("dbo_p3.png",
plot = dbo_p3,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 8 rows containing non-finite values (stat_boxplot).
## Removed 8 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 8 rows containing missing values (position_quasirandom).
ggsave("dbo_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(dbo_p1, dbo_p2, dbo_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 22 rows containing non-finite values (stat_boxplot).
## Removed 22 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 22 rows containing missing values (position_quasirandom).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 30 rows containing non-finite values (stat_boxplot).
## Removed 30 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 30 rows containing missing values (position_quasirandom).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 8 rows containing non-finite values (stat_boxplot).
## Removed 8 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 8 rows containing missing values (position_quasirandom).
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
###
Fósforo total
(ptot_p1<-ggplot(plan_wide_19902020%>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
`Fósforo total`))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.15,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.1,
ymax=0.15,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=0.1,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Fósforo total no período 1990-2000",
x="Estação",
y="mg/L")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.03,0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$`Fósforo total`, na.rm = TRUE),
max(plan_wide_19902020$`Fósforo total`), na.rm = TRUE),
trans = "log10")+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)(ptot_p2 <- ggplot(plan_wide_19902020%>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
`Fósforo total`))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.15,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.1,
ymax=0.15,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=0.1,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Fósforo total no período 2000-2010",
x="Estação",
y="mg/L")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.03,0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$`Fósforo total`, na.rm = TRUE),
max(plan_wide_19902020$`Fósforo total`), na.rm = TRUE),
trans = "log10")+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)(ptot_p3 <- ggplot(plan_wide_19902020%>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
`Fósforo total`))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.15,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.1,
ymax=0.15,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=0.1,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Fósforo total no período 2010-2020",
x="Estação",
y="mg/L")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.03,0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$`Fósforo total`, na.rm = TRUE),
max(plan_wide_19902020$`Fósforo total`), na.rm = TRUE),
trans = "log10")+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)grid.arrange(ptot_p1, ptot_p2, ptot_p3, ncol = 3)(sum_ptot_p1 <- plan_wide_19902020 %>%
select(CODIGO, `Fósforo total`, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(`Fósforo total`, na.rm = TRUE),
q1 =
quantile(`Fósforo total`, 0.25, na.rm = TRUE),
median =
median(`Fósforo total`, na.rm = TRUE),
mean =
mean(`Fósforo total`, na.rm= TRUE),
q3 =
quantile(`Fósforo total`, 0.75, na.rm = TRUE),
max =
max(`Fósforo total`, na.rm = TRUE)))## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.0097 0.0593 0.0881 0.123 0.14 0.863
## 2 87398900 0.0023 0.0468 0.0678 0.0747 0.0883 0.247
## 3 87398950 0.0202 0.0544 0.0737 0.0751 0.0904 0.179
## 4 87398980 0.01 0.0254 0.0547 0.0708 0.114 0.189
## 5 87405500 0.017 0.171 0.281 0.417 0.492 2.32
## 6 87406900 0.156 0.270 0.508 0.785 1.07 2.79
## 7 87409900 0.107 0.258 0.384 0.489 0.712 1.53
(sum_ptot_p2 <- plan_wide_19902020 %>%
select(CODIGO, `Fósforo total`, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(`Fósforo total`, na.rm = TRUE),
q1 =
quantile(`Fósforo total`, 0.25, na.rm = TRUE),
median =
median(`Fósforo total`, na.rm = TRUE),
mean =
mean(`Fósforo total`, na.rm= TRUE),
q3 =
quantile(`Fósforo total`, 0.75, na.rm = TRUE),
max =
max(`Fósforo total`, na.rm = TRUE)))## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.025 0.094 0.131 0.148 0.16 0.637
## 2 87398900 0.015 0.0764 0.104 0.140 0.164 0.646
## 3 87398950 0.036 0.116 0.171 0.180 0.207 0.485
## 4 87398980 0.0115 0.052 0.076 0.101 0.103 1
## 5 87405500 0.046 0.261 0.406 0.547 0.681 1.98
## 6 87406900 0.056 0.338 0.599 0.752 0.967 3.49
## 7 87409900 0.043 0.325 0.624 0.677 0.989 1.57
(sum_ptot_p3 <- plan_wide_19902020 %>%
select(CODIGO, `Fósforo total`, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(`Fósforo total`, na.rm = TRUE),
q1 =
quantile(`Fósforo total`, 0.25, na.rm = TRUE),
median =
median(`Fósforo total`, na.rm = TRUE),
mean =
mean(`Fósforo total`, na.rm= TRUE),
q3 =
quantile(`Fósforo total`, 0.75, na.rm = TRUE),
max =
max(`Fósforo total`, na.rm = TRUE)))## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.061 0.118 0.163 0.166 0.186 0.381
## 2 87398900 0.057 0.0935 0.130 0.163 0.168 0.444
## 3 87398950 0.07 0.132 0.156 0.292 0.221 3.11
## 4 87398980 0.019 0.0625 0.106 0.144 0.170 0.59
## 5 87405500 0.013 0.187 0.332 0.361 0.45 0.803
## 6 87406900 0.089 0.254 0.364 0.448 0.560 1.26
## 7 87409900 0.203 0.259 0.369 0.488 0.564 1.7
ggsave("ptot_p1.png",
plot = ptot_p1,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 47 rows containing non-finite values (stat_boxplot).
## Removed 47 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 47 rows containing missing values (position_quasirandom).
ggsave("ptot_p2.png",
plot = ptot_p2,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 31 rows containing non-finite values (stat_boxplot).
## Removed 31 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 31 rows containing missing values (position_quasirandom).
ggsave("ptot_p3.png",
plot = ptot_p3,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 54 rows containing non-finite values (stat_boxplot).
## Removed 54 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 54 rows containing missing values (position_quasirandom).
ggsave("ptot_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(ptot_p1, ptot_p2, ptot_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 47 rows containing non-finite values (stat_boxplot).
## Removed 47 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 47 rows containing missing values (position_quasirandom).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 31 rows containing non-finite values (stat_boxplot).
## Removed 31 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 31 rows containing missing values (position_quasirandom).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 54 rows containing non-finite values (stat_boxplot).
## Removed 54 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 54 rows containing missing values (position_quasirandom).
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
(ecoli_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
`Escherichia coli`))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3200,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=800,
ymax=3200,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=160,
ymax=800,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=160,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Escherichia coli no período 1990-2000",
x="Estação",
y="NMP/100mL")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$`Escherichia coli`, na.rm = TRUE),
max(plan_wide_19902020$`Escherichia coli`, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)(ecoli_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
`Escherichia coli`))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3200,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=800,
ymax=3200,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=160,
ymax=800,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=160,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Escherichia coli no período 2000-2010",
x="Estação",
y="NMP/100mL")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$`Escherichia coli`, na.rm = TRUE),
max(plan_wide_19902020$`Escherichia coli`, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)(ecoli_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
`Escherichia coli`))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3200,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=800,
ymax=3200,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=160,
ymax=800,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=160,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Escherichia coli no período 2010-2020",
x="Estação",
y="NMP/100mL")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$`Escherichia coli`, na.rm = TRUE),
max(plan_wide_19902020$`Escherichia coli`, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)grid.arrange(ecoli_p1, ecoli_p2, ecoli_p3, ncol = 3)(sum_ecoli_p1 <- plan_wide_19902020 %>%
select(CODIGO, `Escherichia coli`, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(`Escherichia coli`,
na.rm = TRUE),
q1 =
quantile(`Escherichia coli`, 0.25,
na.rm = TRUE),
median =
median(`Escherichia coli`,
na.rm = TRUE),
mean =
mean(`Escherichia coli`,
na.rm= TRUE),
q3 =
quantile(`Escherichia coli`, 0.75,
na.rm = TRUE),
max =
max(`Escherichia coli`,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 32 136 240 854. 720 19200
## 2 87398900 16 68 160 548. 480 7760
## 3 87398950 2.4 12.8 268 4039. 10000 28000
## 4 87398980 4 160 243. 2907. 446 25600
## 5 87405500 1.6 12.8 24 545. 128 18400
## 6 87406900 13.6 61.6 192 718. 414 12800
## 7 87409900 2.4 12.8 64 97.7 128 720
(sum_ecoli_p2 <- plan_wide_19902020 %>%
select(CODIGO, `Escherichia coli`, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(`Escherichia coli`,
na.rm = TRUE),
q1 =
quantile(`Escherichia coli`, 0.25,
na.rm = TRUE),
median =
median(`Escherichia coli`,
na.rm = TRUE),
mean =
mean(`Escherichia coli`,
na.rm= TRUE),
q3 =
quantile(`Escherichia coli`, 0.75,
na.rm = TRUE),
max =
max(`Escherichia coli`,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 21.6 91 150 1335. 308 27200
## 2 87398900 11 70 133. 444. 414. 2600
## 3 87398950 20 400 720 935. 1120 5500
## 4 87398980 24 110. 195 410. 289. 8800
## 5 87405500 4.7 162 2400 25445. 12950 490000
## 6 87406900 8 172 12800 66370. 62300 650000
## 7 87409900 16 7355. 35500 72440. 68750 460000
(sum_ecoli_p3 <- plan_wide_19902020 %>%
select(CODIGO, `Escherichia coli`, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(`Escherichia coli`,
na.rm = TRUE),
q1 =
quantile(`Escherichia coli`, 0.25,
na.rm = TRUE),
median =
median(`Escherichia coli`,
na.rm = TRUE),
mean =
mean(`Escherichia coli`,
na.rm= TRUE),
q3 =
quantile(`Escherichia coli`, 0.75,
na.rm = TRUE),
max =
max(`Escherichia coli`,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 90 155. 260 409. 451 2420
## 2 87398900 10 52.8 107 245. 313 1553.
## 3 87398950 108. 250 487 1424. 1553. 10462
## 4 87398980 40.8 140. 242. 529. 738. 2400
## 5 87405500 632 8965 19232. 109992. 70750 1400000
## 6 87406900 1440 23100 34500 230828. 140500 3400000
## 7 87409900 2000 20100 38400 83128. 83680 345000
ggsave("ecoli_p1.png",
plot = ecoli_p1,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 15 rows containing non-finite values (stat_boxplot).
## Removed 15 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 15 rows containing missing values (position_quasirandom).
ggsave("ecoli_p2.png",
plot = ecoli_p2,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 66 rows containing non-finite values (stat_boxplot).
## Removed 66 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 66 rows containing missing values (position_quasirandom).
ggsave("ecoli_p3.png",
plot = ecoli_p3,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 14 rows containing non-finite values (stat_boxplot).
## Removed 14 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 14 rows containing missing values (position_quasirandom).
ggsave("ecoli_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(ecoli_p1, ecoli_p2, ecoli_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 15 rows containing non-finite values (stat_boxplot).
## Removed 15 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 15 rows containing missing values (position_quasirandom).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 66 rows containing non-finite values (stat_boxplot).
## Removed 66 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 66 rows containing missing values (position_quasirandom).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 14 rows containing non-finite values (stat_boxplot).
## Removed 14 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 14 rows containing missing values (position_quasirandom).
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
###
Nitrogênio amoniacal
(namon_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
`Nitrogênio total`))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=13.3,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3.7,
ymax=13.3,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=3.7,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Nitrogênio amoniacal no período 1990-2000",
x="Estação",
y="mg/L")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$`Nitrogênio total`, na.rm = TRUE),
max(plan_wide_19902020$`Nitrogênio total`, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = .001,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)(namon_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
`Nitrogênio total`))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=13.3,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3.7,
ymax=13.3,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=3.7,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Nitrogênio amoniacal no período 2000-2010",
x="Estação",
y="mg/L")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$`Nitrogênio total`, na.rm = TRUE),
max(plan_wide_19902020$`Nitrogênio total`, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = .001,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)(namon_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
`Nitrogênio total`))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=13.3,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3.7,
ymax=13.3,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=3.7,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Nitrogênio amoniacal no período 2010-2020",
x="Estação",
y="mg/L")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$`Nitrogênio total`, na.rm = TRUE),
max(plan_wide_19902020$`Nitrogênio total`, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = .001,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)grid.arrange(namon_p1, namon_p2, namon_p3, ncol = 3)(sum_namon_p1 <- plan_wide_19902020 %>%
select(CODIGO, `Nitrogênio total`, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(`Nitrogênio total`,
na.rm = TRUE),
q1 =
quantile(`Nitrogênio total`, 0.25,
na.rm = TRUE),
median =
median(`Nitrogênio total`,
na.rm = TRUE),
mean =
mean(`Nitrogênio total`,
na.rm= TRUE),
q3 =
quantile(`Nitrogênio total`, 0.75,
na.rm = TRUE),
max =
max(`Nitrogênio total`,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.44 0.842 1.00 1.22 1.34 3.81
## 2 87398900 0.22 0.82 1 1.09 1.25 4.86
## 3 87398950 0.51 0.83 1.02 1.06 1.19 2.16
## 4 87398980 0.549 0.68 0.755 0.872 1.01 1.85
## 5 87405500 0.51 1.53 2.94 5.27 6.77 21.6
## 6 87406900 1.34 2.60 4.56 7.58 11.2 29.1
## 7 87409900 0.5 1.98 4.29 5.18 7.01 19.6
(sum_namon_p2 <- plan_wide_19902020 %>%
select(CODIGO, `Nitrogênio total`, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(`Nitrogênio total`,
na.rm = TRUE),
q1 =
quantile(`Nitrogênio total`, 0.25,
na.rm = TRUE),
median =
median(`Nitrogênio total`,
na.rm = TRUE),
mean =
mean(`Nitrogênio total`,
na.rm= TRUE),
q3 =
quantile(`Nitrogênio total`, 0.75,
na.rm = TRUE),
max =
max(`Nitrogênio total`,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.18 0.885 0.992 1.80 1.46 23.2
## 2 87398900 0.48 0.894 1.13 1.38 1.57 7.92
## 3 87398950 0.57 1.26 1.45 1.43 1.71 1.98
## 4 87398980 0.19 0.685 0.79 1.05 1.10 5.2
## 5 87405500 0.968 2 3.29 5.45 6.60 21.7
## 6 87406900 0.77 2.4 4.54 7.30 10.2 39.1
## 7 87409900 1.62 2.5 6.97 7.92 10.6 21.5
(sum_namon_p3 <- plan_wide_19902020 %>%
select(CODIGO, `Nitrogênio total`, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(`Nitrogênio total`,
na.rm = TRUE),
q1 =
quantile(`Nitrogênio total`, 0.25,
na.rm = TRUE),
median =
median(`Nitrogênio total`,
na.rm = TRUE),
mean =
mean(`Nitrogênio total`,
na.rm= TRUE),
q3 =
quantile(`Nitrogênio total`, 0.75,
na.rm = TRUE),
max =
max(`Nitrogênio total`,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.222 0.89 1.11 1.24 1.41 2.56
## 2 87398900 0.095 0.883 1.02 1.29 1.40 4.25
## 3 87398950 0.612 1.04 1.43 1.90 2.06 9.5
## 4 87398980 0.216 0.973 1.12 1.22 1.58 2.32
## 5 87405500 1.12 2.03 3.14 4.50 5.93 22.0
## 6 87406900 1.37 2.40 5.58 6.47 7.58 25
## 7 87409900 1.11 3 6.15 7.29 7.75 36
ggsave("namon_p1.png",
plot = namon_p1,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 102 rows containing non-finite values (stat_boxplot).
## Removed 102 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 102 rows containing missing values (position_quasirandom).
ggsave("namon_p2.png",
plot = namon_p2,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 110 rows containing non-finite values (stat_boxplot).
## Removed 110 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 110 rows containing missing values (position_quasirandom).
ggsave("namon_p3.png",
plot = namon_p3,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 70 rows containing non-finite values (stat_boxplot).
## Removed 70 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 70 rows containing missing values (position_quasirandom).
ggsave("namon_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(namon_p1, namon_p2, namon_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 102 rows containing non-finite values (stat_boxplot).
## Removed 102 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 102 rows containing missing values (position_quasirandom).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 110 rows containing non-finite values (stat_boxplot).
## Removed 110 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 110 rows containing missing values (position_quasirandom).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 70 rows containing non-finite values (stat_boxplot).
## Removed 70 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 70 rows containing missing values (position_quasirandom).
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
(turb_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
Turbidez))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=100,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=40,
ymax=100,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=40,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Turbidez no período 1990-2000",
x="Estação",
y="UNT")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.05, 0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$Turbidez, na.rm = TRUE),
max(plan_wide_19902020$Turbidez, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)(turb_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
Turbidez))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=100,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=40,
ymax=100,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=40,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Turbidez no período 2000-2010",
x="Estação",
y="UNT")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.05, 0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$Turbidez, na.rm = TRUE),
max(plan_wide_19902020$Turbidez, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)(turb_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
Turbidez))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=100,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=40,
ymax=100,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=40,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Turbidez no período 2010-2020",
x="Estação",
y="UNT")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.05, 0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$Turbidez, na.rm = TRUE),
max(plan_wide_19902020$Turbidez, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)grid.arrange(turb_p1, turb_p2, turb_p3, ncol = 3)(sum_turb_p1 <- plan_wide_19902020 %>%
select(CODIGO, Turbidez, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(Turbidez,
na.rm = TRUE),
q1 =
quantile(Turbidez, 0.25,
na.rm = TRUE),
median =
median(Turbidez,
na.rm = TRUE),
mean =
mean(Turbidez,
na.rm= TRUE),
q3 =
quantile(Turbidez, 0.75,
na.rm = TRUE),
max =
max(Turbidez,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 6.2 19 34.5 63.5 67 461
## 2 87398900 9 19 49.5 61.5 73.8 460
## 3 87398950 9.6 16 22 33.3 48.8 144
## 4 87398980 16 32.8 43 66.8 90.5 190
## 5 87405500 8.5 23.5 47 47.5 58 159
## 6 87406900 33 54.8 67 77.7 81.5 199
## 7 87409900 5.8 15 25 32.2 48 76
(sum_turb_p2 <- plan_wide_19902020 %>%
select(CODIGO, Turbidez, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(Turbidez,
na.rm = TRUE),
q1 =
quantile(Turbidez, 0.25,
na.rm = TRUE),
median =
median(Turbidez,
na.rm = TRUE),
mean =
mean(Turbidez,
na.rm= TRUE),
q3 =
quantile(Turbidez, 0.75,
na.rm = TRUE),
max =
max(Turbidez,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 9 41.2 55.5 71.1 74.2 428
## 2 87398900 39 57 78 107. 116. 475
## 3 87398950 39 47 64 96.5 90 330
## 4 87398980 24 37 50 64.5 87 176
## 5 87405500 32 46 63.5 70.3 76 341
## 6 87406900 35 49 62 69.9 75.5 284
## 7 87409900 40 45 60 70.4 90 151
(sum_turb_p3 <- plan_wide_19902020 %>%
select(CODIGO, Turbidez, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(Turbidez,
na.rm = TRUE),
q1 =
quantile(Turbidez, 0.25,
na.rm = TRUE),
median =
median(Turbidez,
na.rm = TRUE),
mean =
mean(Turbidez,
na.rm= TRUE),
q3 =
quantile(Turbidez, 0.75,
na.rm = TRUE),
max =
max(Turbidez,
na.rm = TRUE))
) ## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 8.52 16.4 29 33.3 43 85
## 2 87398900 14.8 39.2 48.3 66.7 73.4 299
## 3 87398950 16 29.9 41 51.6 65 230
## 4 87398980 11 19.4 33.6 39.5 42.2 110.
## 5 87405500 10.0 29.0 41 42.9 54.5 131
## 6 87406900 9.62 23 39 41.2 52 122
## 7 87409900 9.68 22.0 34.0 40.5 47 182.
ggsave("turb_p1.png",
plot = turb_p1,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 56 rows containing non-finite values (stat_boxplot).
## Removed 56 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 56 rows containing missing values (position_quasirandom).
ggsave("turb_p2.png",
plot = turb_p2,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 74 rows containing non-finite values (stat_boxplot).
## Removed 74 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 74 rows containing missing values (position_quasirandom).
ggsave("turb_p3.png",
plot = turb_p3,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 14 rows containing non-finite values (stat_boxplot).
## Removed 14 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 14 rows containing missing values (position_quasirandom).
ggsave("turb_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(turb_p1, turb_p2, turb_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 56 rows containing non-finite values (stat_boxplot).
## Removed 56 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 56 rows containing missing values (position_quasirandom).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 74 rows containing non-finite values (stat_boxplot).
## Removed 74 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 74 rows containing missing values (position_quasirandom).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 14 rows containing non-finite values (stat_boxplot).
## Removed 14 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 14 rows containing missing values (position_quasirandom).
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
(pH_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
pH))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=6,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=9,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=6,
ymax=9,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "pH no período 1990-2000",
x="Estação",
y="")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 8,
limits = c(4,11),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)(pH_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
pH))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=6,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=9,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=6,
ymax=9,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "pH no período 2000-2010",
x="Estação",
y="")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 8,
limits = c(4,11),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)(pH_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
pH))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=6,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=9,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=6,
ymax=9,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "pH no período 2010-2020",
x="Estação",
y="")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 8,
limits = c(4,11),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)grid.arrange(pH_p1, pH_p2, pH_p3, ncol = 3)(sum_pH_p1 <- plan_wide_19902020 %>%
select(CODIGO, pH, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(pH,
na.rm = TRUE),
q1 =
quantile(pH, 0.25,
na.rm = TRUE),
median =
median(pH,
na.rm = TRUE),
mean =
mean(pH,
na.rm= TRUE),
q3 =
quantile(pH, 0.75,
na.rm = TRUE),
max =
max(pH,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 5 6.18 6.59 6.51 6.82 7.9
## 2 87398900 5.2 6 6.3 6.33 6.63 7.9
## 3 87398950 5.4 6.29 6.4 6.49 6.72 8.1
## 4 87398980 5.3 5.93 6.2 6.16 6.3 7.3
## 5 87405500 5 6.3 6.4 6.47 6.7 9.3
## 6 87406900 5.5 6.18 6.45 6.43 6.8 7.3
## 7 87409900 4.5 6.2 6.4 6.44 6.7 7.4
(sum_pH_p2 <- plan_wide_19902020 %>%
select(CODIGO, pH, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(pH,
na.rm = TRUE),
q1 =
quantile(pH, 0.25,
na.rm = TRUE),
median =
median(pH,
na.rm = TRUE),
mean =
mean(pH,
na.rm= TRUE),
q3 =
quantile(pH, 0.75,
na.rm = TRUE),
max =
max(pH,
na.rm = TRUE))
) ## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 5.3 6.3 6.6 6.59 6.88 7.9
## 2 87398900 5.5 6.4 6.65 6.63 6.9 7.5
## 3 87398950 6 6.6 6.8 6.89 7.25 7.6
## 4 87398980 5.8 6.3 6.5 6.63 7 7.5
## 5 87405500 5.2 6.4 6.6 6.68 6.9 8.3
## 6 87406900 5.5 6.4 6.7 6.66 6.9 8.6
## 7 87409900 5.8 6.5 6.8 6.77 7 8.4
(sum_pH_p3 <- plan_wide_19902020 %>%
select(CODIGO, pH, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(pH,
na.rm = TRUE),
q1 =
quantile(pH, 0.25,
na.rm = TRUE),
median =
median(pH,
na.rm = TRUE),
mean =
mean(pH,
na.rm= TRUE),
q3 =
quantile(pH, 0.75,
na.rm = TRUE),
max =
max(pH,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 5.47 6.28 6.42 6.47 6.60 7.3
## 2 87398900 5.68 6.36 6.5 6.57 6.84 7.4
## 3 87398950 5.71 6.28 6.46 6.46 6.68 7
## 4 87398980 5.42 6.10 6.36 6.39 6.6 7.2
## 5 87405500 5.64 6.34 6.5 6.49 6.7 7.01
## 6 87406900 5.6 6.4 6.48 6.51 6.77 7.3
## 7 87409900 5.59 6.46 6.6 6.57 6.76 7.2
ggsave("pH_p1.png",
plot = pH_p1,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).
## Removed 1 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing missing values (position_quasirandom).
ggsave("pH_p2.png",
plot = pH_p2,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Removed 73 rows containing non-finite values (stat_boxplot).
## Removed 73 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 73 rows containing missing values (position_quasirandom).
ggsave("pH_p3.png",
plot = pH_p3,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Removed 14 rows containing non-finite values (stat_boxplot).
## Removed 14 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 14 rows containing missing values (position_quasirandom).
ggsave("pH_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(pH_p1, pH_p2, pH_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")## Warning: Removed 1 rows containing non-finite values (stat_boxplot).
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing missing values (position_quasirandom).
## Warning: Removed 73 rows containing non-finite values (stat_boxplot).
## Removed 73 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 73 rows containing missing values (position_quasirandom).
## Warning: Removed 14 rows containing non-finite values (stat_boxplot).
## Removed 14 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 14 rows containing missing values (position_quasirandom).
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
(SolTot_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
`Sólidos totais`))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=500,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Sólidos totais no período 1990-2000",
x="Estação",
y="")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$`Sólidos totais`, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)(SolTot_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
`Sólidos totais`))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=500,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Sólidos totais no período 2000-2010",
x="Estação",
y="")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$`Sólidos totais`, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)(SolTot_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
`Sólidos totais`))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=500,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Sólidos totais no período 2010-2020",
x="Estação",
y="")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$`Sólidos totais`, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)grid.arrange(SolTot_p1, SolTot_p2, SolTot_p3, ncol = 3)(sum_SolTot_p1 <- plan_wide_19902020 %>%
select(CODIGO, `Sólidos totais`, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(`Sólidos totais`,
na.rm = TRUE),
q1 =
quantile(`Sólidos totais`, 0.25,
na.rm = TRUE),
median =
median(`Sólidos totais`,
na.rm = TRUE),
mean =
mean(`Sólidos totais`,
na.rm= TRUE),
q3 =
quantile(`Sólidos totais`, 0.75,
na.rm = TRUE),
max =
max(`Sólidos totais`,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 46 84.5 95 122. 120 510
## 2 87398900 18 74.5 97 111. 122. 474
## 3 87398950 10 76.5 91 90.9 106. 155
## 4 87398980 48 63.5 81.5 104. 126. 337
## 5 87405500 70 101 121 133. 151 361
## 6 87406900 89 118 155 165. 210 279
## 7 87409900 20 99.5 122 128. 143 381
(sum_SolTot_p2 <- plan_wide_19902020 %>%
select(CODIGO, `Sólidos totais`, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(`Sólidos totais`,
na.rm = TRUE),
q1 =
quantile(`Sólidos totais`, 0.25,
na.rm = TRUE),
median =
median(`Sólidos totais`,
na.rm = TRUE),
mean =
mean(`Sólidos totais`,
na.rm= TRUE),
q3 =
quantile(`Sólidos totais`, 0.75,
na.rm = TRUE),
max =
max(`Sólidos totais`,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 28 80 100 111. 123. 412
## 2 87398900 42 82 102. 128. 140. 489
## 3 87398950 46 94.2 108. 126. 127. 318
## 4 87398980 40 61 77 85.3 96 228
## 5 87405500 48 102 133 148. 170. 522
## 6 87406900 50 109 134. 154. 170. 670
## 7 87409900 56 112. 156 167. 190. 599
(sum_SolTot_p3 <- plan_wide_19902020 %>%
select(CODIGO, `Sólidos totais`, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(`Sólidos totais`,
na.rm = TRUE),
q1 =
quantile(`Sólidos totais`, 0.25,
na.rm = TRUE),
median =
median(`Sólidos totais`,
na.rm = TRUE),
mean =
mean(`Sólidos totais`,
na.rm= TRUE),
q3 =
quantile(`Sólidos totais`, 0.75,
na.rm = TRUE),
max =
max(`Sólidos totais`,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 61 69 90 82.8 96 101
## 2 87398900 41 77 104 120. 127 308
## 3 87398950 45 93 101 109. 117 221
## 4 87398980 55 62.8 80 79.9 95 109
## 5 87405500 83 89.2 108. 124. 162. 195
## 6 87406900 50 106 117 135. 163 246
## 7 87409900 75 103 115 131. 145 251
ggsave("SolTot_p1.png",
plot = SolTot_p1,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Removed 10 rows containing non-finite values (stat_boxplot).
## Removed 10 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 10 rows containing missing values (position_quasirandom).
ggsave("SolTot_p2.png",
plot = SolTot_p2,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Removed 7 rows containing non-finite values (stat_boxplot).
## Removed 7 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 7 rows containing missing values (position_quasirandom).
ggsave("SolTot_p3.png",
plot = SolTot_p3,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Removed 125 rows containing non-finite values (stat_boxplot).
## Removed 125 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 125 rows containing missing values (position_quasirandom).
ggsave("SolTot_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(SolTot_p1, SolTot_p2, SolTot_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")## Warning: Removed 10 rows containing non-finite values (stat_boxplot).
## Warning: Removed 10 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 10 rows containing missing values (position_quasirandom).
## Warning: Removed 7 rows containing non-finite values (stat_boxplot).
## Removed 7 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 7 rows containing missing values (position_quasirandom).
## Warning: Removed 125 rows containing non-finite values (stat_boxplot).
## Removed 125 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 125 rows containing missing values (position_quasirandom).
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
grid.arrange(iqa_p1, iqa_p2, iqa_p3, ncol = 3)(sum_IQA_p1 <- plan_wide_19902020 %>%
select(CODIGO, IQA, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(IQA,
na.rm = TRUE),
q1 =
quantile(IQA, 0.25,
na.rm = TRUE),
median =
median(IQA,
na.rm = TRUE),
mean =
mean(IQA,
na.rm= TRUE),
q3 =
quantile(IQA, 0.75,
na.rm = TRUE),
max =
max(IQA,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 27.0 35.7 40.9 40.7 46.2 52.2
## 2 87398900 27.8 37.9 42.9 43.0 48.0 58.5
## 3 87398950 32.8 36.8 41.4 43.2 48.6 61.9
## 4 87398980 29.2 35.8 40.4 40.3 44.8 51.9
## 5 87405500 24.8 34.9 41.2 40.3 46.9 57.6
## 6 87406900 24.7 31.3 37.8 37.4 44.4 49.0
## 7 87409900 23.6 31.9 37.1 38.8 46.2 55.4
(sum_IQA_p2 <- plan_wide_19902020 %>%
select(CODIGO, IQA, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(IQA,
na.rm = TRUE),
q1 =
quantile(IQA, 0.25,
na.rm = TRUE),
median =
median(IQA,
na.rm = TRUE),
mean =
mean(IQA,
na.rm= TRUE),
q3 =
quantile(IQA, 0.75,
na.rm = TRUE),
max =
max(IQA,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 27.8 34.6 40.0 39.5 43.5 48.7
## 2 87398900 28.5 35.1 37.6 38.3 40.6 48.5
## 3 87398950 21.1 29.4 32.7 32.8 36.8 44.0
## 4 87398980 24.5 35.7 39.4 39.5 43.4 52.1
## 5 87405500 19.8 28.7 31.5 31.9 35.7 48.8
## 6 87406900 17.1 25.3 29.0 29.5 32.8 44.1
## 7 87409900 16.2 20.5 26.1 25.0 29.8 33.1
(sum_IQA_p3 <- plan_wide_19902020 %>%
select(CODIGO, IQA, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(IQA,
na.rm = TRUE),
q1 =
quantile(IQA, 0.25,
na.rm = TRUE),
median =
median(IQA,
na.rm = TRUE),
mean =
mean(IQA,
na.rm= TRUE),
q3 =
quantile(IQA, 0.75,
na.rm = TRUE),
max =
max(IQA,
na.rm = TRUE),
n =
length(IQA))
)## # A tibble: 7 x 8
## CODIGO min q1 median mean q3 max n
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
## 1 87398500 40.2 42.5 45.4 44.2 45.5 47.2 34
## 2 87398900 34.1 38.6 41.2 40.2 42.9 44.4 36
## 3 87398950 36.7 39.5 42.4 41.5 44.4 44.6 35
## 4 87398980 40.0 40.0 40.0 40.0 40.0 40.0 28
## 5 87405500 30.8 31.6 32.5 32.5 33.3 34.1 33
## 6 87406900 22.9 24.4 25.9 25.3 26.5 27.2 35
## 7 87409900 24.1 25.1 27.3 26.9 28.2 29.7 37
plan_wide_19902020 %>%
select(CODIGO, IQA) %>%
group_by(CODIGO) %>%
summarize(
min =
min(IQA,
na.rm = TRUE),
q1 =
quantile(IQA, 0.25,
na.rm = TRUE),
median =
median(IQA,
na.rm = TRUE),
mean =
mean(IQA,
na.rm= TRUE),
q3 =
quantile(IQA, 0.75,
na.rm = TRUE),
max =
max(IQA,
na.rm = TRUE))## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 27.0 35.6 40.7 40.5 45.4 52.2
## 2 87398900 27.8 36.4 40.7 41.4 46.1 58.5
## 3 87398950 21.1 36.6 40.7 41.8 47.4 61.9
## 4 87398980 24.5 35.7 39.7 39.9 44.1 52.1
## 5 87405500 19.8 29.9 36.9 37.3 44.0 57.6
## 6 87406900 17.1 25.7 31.1 32.4 38.0 49.0
## 7 87409900 16.2 28.1 33.2 35.3 42.7 55.4
ggsave("iqa_p1.png",
plot = iqa_p1,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 164 rows containing missing values (position_quasirandom).
ggsave("iqa_p2.png",
plot = iqa_p2,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 253 rows containing missing values (position_quasirandom).
ggsave("iqa_p3.png",
plot = iqa_p3,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 214 rows containing missing values (position_quasirandom).
ggsave("iqa_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(iqa_p1, iqa_p2, iqa_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 164 rows containing missing values (position_quasirandom).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 253 rows containing missing values (position_quasirandom).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 214 rows containing missing values (position_quasirandom).
## Using ragg device as default. Ignoring `type` and `antialias` arguments
parametros_IQA <- plan_wide_19902020 %>%
select(CODIGO,
pH,
DBO,
`Nitrogênio amoniacal`,
`Nitrogênio total`,
`Fósforo total`,
`Temperatura água`,
Turbidez,
`Sólidos totais`,
`Oxigênio dissolvido`,
Condutividade)
write.csv(parametros_IQA,
"./parametros_IQA.csv",
row.names = FALSE)
parametros_IQA %>%
select(-CODIGO) %>%
ggcorr(method = "complete.obs",
# "pearson",
# "pairwise",
name = "Correlação",
label = TRUE,
label_alpha = TRUE,
digits = 3,
low = "#3B9AB2",
mid = "#EEEEEE",
high = "#F21A00",
# palette = "RdYlBu",
layout.exp = 0,
legend.position = "left",
label_round = 3,
)# Gráfico das correlações entre todos os parâmetros com significância
# correl_IQA <- parametros_IQA %>%
# select(-CODIGO) %>%
# ggpairs(title = "Correlação entre parâmetros que compõem o IQA",
# axisLabels = "show")(cond_elet_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
Condutividade))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=500,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Condutividade elétrica no período 1990-2000",
x="Estação",
y="")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$Condutividade, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme(
plot.title = element_text(
hjust = 0.5,
color = "black",
size = 19),
axis.title.y = element_text(
color = "black",
size = 15),
axis.text.y = element_text(
color = "black",
size = 17),
axis.text.x = element_text(
color = "black",
size = 17),
)
)(cond_elet_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
Condutividade))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=500,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Condutividade elétrica no período 1990-2000",
x="Estação",
y="")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$Condutividade, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme(
plot.title = element_text(
hjust = 0.5,
color = "black",
size = 19),
axis.title.y = element_text(
color = "black",
size = 15),
axis.text.y = element_text(
color = "black",
size = 17),
axis.text.x = element_text(
color = "black",
size = 17),
)
)(cond_elet_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
Condutividade))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=500,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = 1, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Condutividade elétrica no período 1990-2000",
x="Estação",
y="")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$Condutividade, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
scale_x_discrete(limits = c("87398500", "87398980", "87398900",
"87398950", "87405500", "87406900", "87409900"))+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme(
plot.title = element_text(
hjust = 0.5,
color = "black",
size = 19),
axis.title.y = element_text(
color = "black",
size = 15),
axis.text.y = element_text(
color = "black",
size = 17),
axis.text.x = element_text(
color = "black",
size = 17),
)
)grid.arrange(cond_elet_p1, cond_elet_p2, cond_elet_p3, ncol = 3)(sum_cond_elet_p1 <- plan_wide_19902020 %>%
select(CODIGO, Condutividade, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(Condutividade,
na.rm = TRUE),
q1 =
quantile(Condutividade, 0.25,
na.rm = TRUE),
median =
median(Condutividade,
na.rm = TRUE),
mean =
mean(Condutividade,
na.rm= TRUE),
q3 =
quantile(Condutividade, 0.75,
na.rm = TRUE),
max =
max(Condutividade,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 9.4 51.1 67 75.1 83.2 340
## 2 87398900 10 41.5 51 55.3 64.2 160
## 3 87398950 9 41.5 51.5 60.1 69.5 160
## 4 87398980 11.3 42.4 52.0 53.0 67.0 83.8
## 5 87405500 25 68.7 88.2 130. 170 560
## 6 87406900 52 88.4 133. 193. 256. 576
## 7 87409900 29 80 110. 134. 168. 460
(sum_cond_elet_p2 <- plan_wide_19902020 %>%
select(CODIGO, Condutividade, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(Condutividade,
na.rm = TRUE),
q1 =
quantile(Condutividade, 0.25,
na.rm = TRUE),
median =
median(Condutividade,
na.rm = TRUE),
mean =
mean(Condutividade,
na.rm= TRUE),
q3 =
quantile(Condutividade, 0.75,
na.rm = TRUE),
max =
max(Condutividade,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 11.9 67.0 82.6 84.8 102. 164.
## 2 87398900 11 44.4 52.3 57.1 72.6 136.
## 3 87398950 39.8 58.4 76 82.3 98.3 160
## 4 87398980 9.4 42.4 49.7 51.5 62 114.
## 5 87405500 17 77.5 107 142. 171. 679
## 6 87406900 23.1 85.6 124. 164. 199. 619
## 7 87409900 56.1 114. 177 200. 242 454
(sum_cond_elet_p3 <- plan_wide_19902020 %>%
select(CODIGO, Condutividade, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(Condutividade,
na.rm = TRUE),
q1 =
quantile(Condutividade, 0.25,
na.rm = TRUE),
median =
median(Condutividade,
na.rm = TRUE),
mean =
mean(Condutividade,
na.rm= TRUE),
q3 =
quantile(Condutividade, 0.75,
na.rm = TRUE),
max =
max(Condutividade,
na.rm = TRUE),
n =
length(Condutividade))
)## # A tibble: 7 x 8
## CODIGO min q1 median mean q3 max n
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
## 1 87398500 0.01 68.5 80.2 80.4 99.5 125. 34
## 2 87398900 39.7 53.4 58.3 61.1 65.5 103 36
## 3 87398950 40.9 64.7 70.1 76.1 82.5 195. 35
## 4 87398980 43.2 51.7 54.0 56.3 61.0 78.9 28
## 5 87405500 47 85.8 121. 146. 209. 286 33
## 6 87406900 62.7 95.9 142. 163. 216. 354. 35
## 7 87409900 65.7 121. 159. 179. 245. 498. 37
# plan_wide_19902020 %>%
# select(CODIGO, IQA) %>%
# group_by(CODIGO) %>%
# summarize(
# min =
# min(IQA,
# na.rm = TRUE),
# q1 =
# quantile(IQA, 0.25,
# na.rm = TRUE),
# median =
# median(IQA,
# na.rm = TRUE),
# mean =
# mean(IQA,
# na.rm= TRUE),
# q3 =
# quantile(IQA, 0.75,
# na.rm = TRUE),
# max =
# max(IQA,
# na.rm = TRUE))ggsave("cond_elet_p1.png",
plot = cond_elet_p1,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Removed 15 rows containing non-finite values (stat_boxplot).
## Removed 15 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 15 rows containing missing values (position_quasirandom).
ggsave("cond_elet_p2.png",
plot = cond_elet_p2,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Removed 37 rows containing non-finite values (stat_boxplot).
## Removed 37 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 37 rows containing missing values (position_quasirandom).
ggsave("cond_elet_p3.png",
plot = cond_elet_p3,
path = "./graficos",
dpi = 300,
type = "cairo")## Saving 10 x 6.66 in image
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments
## Warning: Removed 25 rows containing non-finite values (stat_boxplot).
## Removed 25 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 25 rows containing missing values (position_quasirandom).
ggsave("cond_elet_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(cond_elet_p1, cond_elet_p2, cond_elet_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")## Warning: Removed 15 rows containing non-finite values (stat_boxplot).
## Warning: Removed 15 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 15 rows containing missing values (position_quasirandom).
## Warning: Removed 37 rows containing non-finite values (stat_boxplot).
## Removed 37 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 37 rows containing missing values (position_quasirandom).
## Warning: Removed 25 rows containing non-finite values (stat_boxplot).
## Removed 25 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 25 rows containing missing values (position_quasirandom).
## Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments